$(document).ready(function () {
    $.ajax({
        url : 'loginCheck',
        type : 'post',
        dataType : 'text',
        data : {account: '123', psword: '456'},
        success : function(data) {
            var result = data;
            switch (result) {
                case "success":
                    alert("成功");
                    break;
                case "wrongPsword":
                    alert("密码错误");
                    break;
                case "notExist":
                    alert("账号不存在");
                    break;
            }
        },
        error : function(data) {
            alert("失败");
        },
    });
})

function login() {

    var account = $("#account").val();
    var psword = $("#psword").val();

    $.ajax({
        url : 'loginCheck',
        type : 'post',
        dataType : 'text',
        data : {account: account, psword: psword},
        success : function(data) {
            var result = data;
            switch (result) {
                case "success":
                    window.location.href = data.url || "main";
                    break;
                case "wrongPsword":
                    alert("密码错误");
                    break;
                case "notExist":
                    alert("账号不存在");
                    break;
            }
        },
        error : function(data) {
            alert("失败");
        },
    });

}
